package com.theme.passport.service.theme.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.theme.common.mvc.utils.PageUtils;
import com.theme.common.mvc.utils.Query;
import com.theme.passport.dao.theme.WidgeTypeAttributeDao;
import com.theme.passport.entity.theme.WidgeTypeAttributeEntity;
import com.theme.passport.service.theme.WidgeTypeAttributeService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("widgeTypeAttributeService")
public class WidgeTypeAttributeServiceImpl extends ServiceImpl<WidgeTypeAttributeDao, WidgeTypeAttributeEntity> implements WidgeTypeAttributeService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<WidgeTypeAttributeEntity> page = this.page(
                new Query<WidgeTypeAttributeEntity>().getPage(params),
                new QueryWrapper<WidgeTypeAttributeEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<WidgeTypeAttributeEntity> listByTypeId(Map<String, Object> params) {
        String widgeTypeId = (String) params.get("widgeTypeId");
        Wrapper<WidgeTypeAttributeEntity> queryWrapper = new QueryWrapper<WidgeTypeAttributeEntity>()
                .eq("status", 1)
                .eq("widge_type_id", widgeTypeId);

        List<WidgeTypeAttributeEntity> widgeConfigEntities = this.baseMapper.selectList(queryWrapper);

        return widgeConfigEntities;

    }

}